package com.sql.db;
/**
 * sql拼接测试代码
 * @author 梁前武 
 * www.apkplug.com
 */
public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		 //1
		 sqlHandle sql1=new sqlHandle();
	     sql1.Add("select * from user where " ,"",null).
	     Add("name=?","", "liling").
	     Add("age=?","and", 10);
	     System.out.println(sql1);   
	     //select * from user where    name=?  and age=? 
	     sql1.AddMore("LIMIT ?,?", "", new Object[]{1,2});
	     System.out.println(sql1);
	     //select * from user where    name=?  and age=?   LIMIT ?,? 
	     
	     //2
	     sqlHandle sql2=new sqlHandle();
	     sql2.Add("select * from friend where " ,"",null).
	     Add("myfriend=?","", "liling");
	     System.out.println(sql2);
	     // select * from friend where    myfriend=? 
	     sql1.AddMoreAndRep(" in(%s) ",sql2, "and", null);
	     System.out.println(sql1);
	     //select * from user where    name=?  and age=?   LIMIT ?,?  and  
	     //in(  select * from friend where    myfriend=? )  
	     //很明显sqlHandle添加时的顺序很关键
	     
	}

}